@extends('Admin.layout.layout')
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <div class="col-sm-11">
                            <h5>商品详情</h5>
                        </div>
                        <div class="col-sm-1">
                            <div class="bottom-con">
                                <a class ="btn btn-s-m btn-default" href="{{asset('/foradmin/product')}}">返回</a>
                            </div>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="signupForm">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">商品标题：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static">{{$data['product_desc']}}</p>
                                </div>
                            </div>
                            @if($data['product_type'] == 2)
                            <?php foreach($data['pattrs'] as $pattr){
                                $a = explode(",",$pattr);
                                if(isset($a[0])){
                                    $p1 = explode(":",$a[0]);
                                }
                                if(isset($a[1])){
                                    $p2 = explode(":",$a[1]);
                                }
                                
                            ?>
                              <div class="form-group">
                                <label class="col-sm-3 control-label"></label>
                                <div class="col-sm-8">
                                    <p class="form-control-static">{{$p1[1]}}：{{$p2[1]}}</p>
                                </div>
                            </div>
                            <?php }?>
                            @endif
                            @if($data['product_type'] == 1)
                            <div class="form-group">
                                <label class="col-sm-3 control-label">商品属性：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static">产品名称：{{$data['name']}}</p>
                                    <p class="form-control-static">自定义分类：{{$data['custom_cate']}}</p>
                                    <p class="form-control-static">品牌：{{$data['brand_name']}}</p>
                                    <p class="form-control-static">型号：{{$data['model']}}</p>
                                    <p class="form-control-static">关键词：{{$data['keywords']}}</p>
                                </div>
                            </div>
                            @endif
                            <div class="form-group">
                                <label class="col-sm-3 control-label">列表图：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static"><img width="100" src="{{$data['cover_image']}}"></p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">主图(详情页)：</label>
                                <div class="col-sm-8">
                                <?php if(isset($data['images'])){
                                    $imgs = json_decode($data['images'],true);
                                    if(is_array($imgs)){
                                        foreach($imgs as $img){
                                          echo "<p class='form-control-static'><img width='100' src='".$img."'></p>";
                                        }
                                    }
                                }
                                ?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">产地：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static">{{$data['place_origin']}}</p>
                                </div>
                            </div>
                            @if($data['product_type'] == 1)
                            <div class="form-group">
                                <label class="col-sm-3 control-label">计量单位：</label>
                                <div class="col-sm-8">
                                    <div class="input-group"> 
                                       <?php $unit_arr = [1=>'个', 2=>'台', 3=>'件',4=>'箱', 5=>'米',6=>'对', 7=>'根',8=>'支', 9=>'100米',10=>'套'];
                                    if(isset($data['unit'],$unit_arr)){
                                        echo '<p class="form-control-static">'.$unit_arr[$data['unit']].'</p>';
                                    }
                                    ?>
                                      
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">发货周期：</label>
                                <div class="col-sm-2">
                                 <?php $delivery_time_arr = [1=>'3-5个工作日', 2=>'6-9个工作日', 3=>'10-15个工作日'];
                                 if(isset($delivery_time_arr[$data['delivery_time']])){
                                     echo '<p class="form-control-static">'.$delivery_time_arr[$data['delivery_time']].'</p>';
                                 }else{
                                     echo '<p class="form-control-static">'.$data['delivery_time'].'</p>';
                                 }
                                    ?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">保质期：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static"> @if(is_numeric($data['guarantee_period'])) {{$data['guarantee_period']}}年 @else {{$data['guarantee_period']}} @endif</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">是否优惠促销：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static">@if($data['is_onsales']==1)是@else 否@endif</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">是否推荐：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static">@if($data['is_recommend']==1)是@else 否@endif</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">是否热门产品：</label>
                                <div class="col-sm-8">
                                    <p class="form-control-static">@if($data['is_hot']==1)是@else 否@endif</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">商品规格：</label>
                                <div class="col-sm-8">
                                    <table class="table table-bordered text-center">
                                        <tbody>
                                            <tr>
                                            <?php if(isset($data['skus'][0]) ){
                                                    $attrs = explode(";",$data['skus'][0]['attributes']);
                                                    if(is_array($attrs)){
                                                        foreach($attrs as $attr){
                                                            $attr = explode(",",$attr);
                                                            if(isset($attr[0])){
                                                                $n = explode(":",$attr[0]);
                                                                if(isset($n[1]) && $n[1]){
                                                                    echo '<th width="50" class="text-center">'.$n[1].'</th>';
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                 ?>
                                                
                                                <th width="50" class="text-center">价格(元)</th>
                                                <th width="50" class="text-center">促销价(元)</th>
                                                <th width="50" class="text-center">库存数</th>
                                                <th width="50" class="text-center">商家编码</th>
                                                <th width="50" class="text-center">运费</th>
                                            </tr>
                                            <?php if(isset($data['skus']) && is_array($data['skus'])){
                                                foreach($data['skus'] as $sku){
                                                ?>
                                            <tr>
                                            <?php 
                                            $attrs = explode(";",$sku['attributes']);
                                            if(is_array($attrs)){
                                                foreach($attrs as $attr){
                                                    $attr = explode(",",$attr);
                                                    if(isset($attr[1])){
                                                        $n = explode(":",$attr[1]);
                                                        if(isset($n[1]) && $n[1]){
                                                            echo '<td>'.$n[1].'</td>';
                                                        }
                                                    }
                                                }
                                            }
                                            ?>
                                                <td>{{$sku['price']}}</td>
                                                <td>{{$sku['sale_price']}}</td>
                                                <td>{{$sku['stock']}}</td>
                                                <td>{{$sku['seller_code']}}</td>
                                                <td>{{$sku['freight']}}</td>
                                            </tr>
                                            <?php 
                                                }
                                            }?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">售后服务：</label>
                                <div class="col-sm-8">
                                    <div class="checkbox">
                                      <?php $after_sale_guarantee_arr = [0=>'',1=>'提供发票', 2=>'保修服务', 3=>'退货承诺：诺存在质量问题或与描述不符，本店将主动提供退货服务并承担来回邮费'];
                                      $arrs = explode(",",$data['after_sale_guarantee']);
                                      foreach($arrs as $arr){
                                          if($arr && in_array($arr,$after_sale_guarantee_arr)){
                                              echo '<p class="form-control-static">'.$after_sale_guarantee_arr[$arr].'</p>';
                                            }
                                      }
                                    ?>
                                    </div>
                                </div>
                            </div>
                            @endif
                            <div class="form-group">
                                <label class="col-sm-3 control-label">橱窗推荐：</label>
                                <div class="col-sm-8">
                                    <div class="checkbox">
                                        <p class="form-control-static">@if($data['is_cupboard']==1)是@else 否@endif</p>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <script src="{{asset('js/plugins/staps/jquery.steps.min.js')}}"></script>
    <script>
        $(document).ready(function () {
            111
        });
    </script>
@endsection
